package com.onepower.core.modules.service.impl;

import com.onepower.core.modules.repository.entity.SysRoleMenu;
import com.onepower.core.modules.repository.mapper.SysRoleMenuMapper;
import com.onepower.core.modules.service.ISysRoleMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 角色和菜单关联表 服务实现类
 * </p>
 *
 * @author kin
 * @since 2018-08-01
 */
@Service
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements ISysRoleMenuService {

    @Override
    public List<Integer> getMenuIdList(Integer roleId) {
        return baseMapper.selectMenuByRoleId(roleId);
    }

    @Override
    public Map<String, String> getRoleMenuList() {
        List<Map<String, String>> maps = baseMapper.selectRoleMenu();
        Map<String, String> roleMaps = new HashMap<>();
        for (Map<String, String> map : maps) {
            roleMaps.put(map.get("url"), map.get("roles"));
        }

        return roleMaps;
    }
}
